package com.itheima.mapper;

import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.io.File;
import java.util.List;

/**
 * @author huangbin
 * @date 2022/6/6 14:48
 */
@Mapper
public interface UserMapper {
    /**
     * 查询所有账号密码
     *
     * @return USER表所有数据
     */
    @Select("select * from user;")
    List<User> selectAll();

    /**
     * 查找用户
     *
     * @param username 账号
     * @param password 密码
     * @return 条数>1找到
     */
    @Select("select * from user where username = #{username} and password = #{password};")
    Integer selectUser(String username, String password);

    /**
     * 添加用户
     *
     * @param user 用户对象
     * @return 成功条数
     */
    @Insert("INSERT INTO user values (null,#{username},#{password});")
    Integer add(User user);
}
